<?php
/**
 * Created by xiaosong
 * E-mail:4155433@gmail.com
 * Date: 2019/10/22
 * Time: 14:09
 */

namespace App\Http\Controllers\api\base;


use App\Http\Controllers\Controller;
use App\Models\RequestLog;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class BaseController extends Controller
{

    use ApiTrait;

    protected $user;

    protected $user_id;

    public function __construct(Request $request,Response $response)
    {

        $this->user_id = getUserId();

        $this->user    = getAuthUser();

        //将所有请求写日志
        $url = $request->getRequestUri();
        $input = json_encode($request->input());
        $response = json_encode($response->getContent());
        $header = json_encode($request->header());
        $data = [
            'url' => $url,
            'input' => $input,
            'response' => $response,
            'header' => $header
        ];
//        $result = RequestLog::create($data);
    }

}